"""Srudyproject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from .views import *
from django.urls import path
from rest_framework.routers import DefaultRouter
router = DefaultRouter()

# 查看资源
router.register('learmate', LearningMaterialsSet)
# 添加、获取学习内容
router.register('studycontents',StudyContentSet)
# 添加、获取分类
router.register('class', ClassSet)

urlpatterns = [
    # 获取学习内容详情
    path('study/<int:pk>/', Study.as_view()),
    # 分类操作
    path("classoper/<int:pk>/", ClassOper.as_view({"put": "update", "delete": "delete"})),
    # 学习内容操作
    path("oper/study/<int:pk>/", OperStudyContent.as_view({"put": "update", "delete": "delete"})),
    # 是否公开学习内容
    path("open/study/<int:pk>/", OpenStudy.as_view()),
    # 发布学习任务
    path("share/task/",ShareTaskAPIView.as_view()),
    # 搜索资源数据
    path("search/",SearchAPIView.as_view()),
    # 学习内容点赞
    path("like/", LikeStudy.as_view()),
    # 获取收藏的内容  收藏内容
    path("collect/", CollectStudy.as_view({"get": "list", "post": "create"}))
]
urlpatterns += router.urls
